!function(){"use strict";let c=null;const l=["debug","info","warn","error"];let s=l.reduce((e,d,a)=>(e[d]=function(){var e="debug"===d?"log":d;if(c&&console&&"function"==typeof console[e]){var t=l.indexOf(c.toString().toLocaleLowerCase());if(!0===c||-1{p[n].push(e),r.push(e[i]),v[n].push(e[i])});for(let n=0;ne[1]).flatMap(e=>e);for(var t of e){let e=t.value.trim();if(w(e)){s.debug("We detected: ",e),g();break}}}catch(e){}r[n]&&r[n](...arguments)};let c=_(e);for(let e=0;e()\[\].,;:\s@"]+(\.[^<>()\[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,}))/i;if(f.detectionSubject.includes("email")&&t.test(e))return e=e.match(t)[0].toLowerCase().trim(),s.debug("We detected email: "+e),d(e,"email"),!0;return!1}(e)||!1}function y(n,i){f.detectDynamicNodes&&new MutationObserver(function(e,t){s.debug("Detected dynamically added nodes."),o[i]=t,r(n,i)}).observe(n,{childList:!0,subtree:!0,attributes:!0})}function i(e){e&&e.type&&e.identifier?"email"!==e.type?s.error("Identifier type is not supported, ",e.type):(d(e.identifier,e.type),g()):s.error("wrong identifier format")}function d(e,t){var n;e&&t&&(n=new CustomEvent("detected-identifier",{detail:{identifier:e,type:t}}),s.info("Dispatched event with identifier: ",e," and type: ",t),window.dispatchEvent(n))}function u(e){if(e&&e.__upixel_detection)try{r(e.__upixel_detection.root,e.__upixel_detection.scopeName)}catch(e){}}function h(t,n,i){s.debug(`collectElements("${n}", ${i})`);let o=[];for(var e of i)0{o.includes(e)||o.push(e)});var r=window.location.hostname,d=document.getElementsByTagName("iframe");for(let e=0;e{o.includes(e)||o.push(e)})}return o}function _(e){return[...e.querySelectorAll("*")].filter(e=>!!e.shadowRoot).map(e=>e.shadowRoot)}window.ttdPixel=window.ttdPixel||{},window.ttdPixel.startDetection=function(e){f=e,s.info("Detection started! Library is configured to detect: ",f.detectionSubject),s.info("Detection event type is ",f.detectionEventType),s.debug("Full config: ",f),"onsubmit"===f.detectionEventType||"onclick"===f.detectionEventType?(e=document.querySelector("body"))&&(r(e,"document"),f.detectDynamicNodes)&&y(e,"document"):s.debug("Detection type not supported! We will not start auto detection."),window.ttdPixelEventsLayer=window.ttdPixelEventsLayer||[],window.ttdPixelEventsLayer.forEach(t),window.ttdPixelEventsLayer.push=function(e){return Array.prototype.push.call(window.ttdPixelEventsLayer,e),t(e),this.length}},window.ttdPixel.setIdentifier=i,window.ttdPixel.enableDebug=()=>e("debug"),window.ttdPixel.disableLog=()=>e(null)}();var ttd_dom_ready=function(){var t,n,i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},u={isReady:!1,readyWait:1,holdReady:function(e){e?u.readyWait++:u.ready(!0)},ready:function(e){if(!0===e&&!--u.readyWait||!0!==e&&!u.isReady){if(!document.body)return setTimeout(u.ready,1);(u.isReady=!0)!==e&&0<--u.readyWait||t.resolveWith(document,[u])}},bindReady:function(){if(!t){if(t=u._Deferred(),"complete"===document.readyState)return setTimeout(u.ready,1);if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",u.ready,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",n),window.attachEvent("onload",u.ready);var e=!1;try{e=null==window.frameElement}catch(e){}document.documentElement.doScroll&&e&&o()}}},_Deferred:function(){var d,n,a,c=[],l={done:function(){if(!a){var e,t,n,i,o,r=arguments;for(d&&(o=d,d=0),e=0,t=r.length;e{var n=document.createElement("script");n.setAttribute("defer",!0),n.setAttribute("src","https://cdn.prod.uidapi.com/uid2-sdk-3.2.0.js"),n.addEventListener("load",()=>{e(),i()}),n.addEventListener("error",e=>{t(e),o(e)}),document.body.appendChild(n)}):(async()=>{try{await window.ttdPixel.uid2SdkLoaderPromise,i()}catch(e){console.warn("Failed to load uid2 sdk: ",e)}})())},this.init=function(r,t,e,d,a){if("string"==typeof arguments[3]&&(arguments[3]=null,4{n=e});var h=null,_=!1,b=null;"function"==typeof __tcfapi?(D=setTimeout(W,1e3),__tcfapi("addEventListener",2,M)):"function"==typeof __cmp?(h=setTimeout(U,1e3),__cmp("ping",null,j)):"function"==typeof __gpp?void 0!==(m=P()).gppString?N(m.gppString,m.gppSid):(E=setTimeout(T,1e3),__gpp("addEventListener",k)):I();let i=!1,o=(void 0!==a&&(i=!0),r+":"+t.join(","));i?this.setupUid2Sdk(o,()=>x(a),e=>{console.warn("UID2 enabled but failed to register hooks: ",e)}):window.addEventListener("message",e=>{try{if(null!==e.origin&&"null"!==e.origin){var t=new URL(e.origin);if(t.hostname.endsWith(".adsrvr.org")&&!i&&"string"==typeof e.data){const n=JSON.parse(e.data);n.advertiserId&&"string"==typeof n.advertiserId&&n.advertiserId==r&&this.setupUid2Sdk(o,()=>x(n),e=>{console.warn("UID2 enabled but failed to register hooks: ",e)})}}}catch(e){}});var E=null,L=!1,D=null,S=!1;function x(a){try{window.__uid2.callbacks.push(async(e,t)=>{switch(e){case"SdkLoaded":try{window.__ttd_m_invoke_once=window.__ttd_m_invoke_once||{},window.__ttd_m_invoke_once._uid2_init||(window.__ttd_m_invoke_once._uid2_init=1,a.baseUrl||(a.baseUrl="https://global.prod.uidapi.com"),__uid2.init({baseUrl:a.baseUrl}))}catch(e){console.info("Non-TTD actor initialized UID2 SDK, mind the consistency of UID2 baseUrl.")}break;case"InitCompleted":var n=()=>t.identity,i=a;try{var o,r,d=n();d?await R(d.advertising_token):window.ttdPixel.activeDetection||(o=new Promise(t=>{window.addEventListener("detected-identifier",function(e){t(e.detail.identifier),window.ttdPixel.activeDetection=null}),window.ttdPixel.startDetection(i)}),r=await(window.ttdPixel.activeDetection=o),await window.__uid2.setIdentityFromEmail(r,i))}catch(e){console.warn("error setting up fireOrDetact: ",e)}await 0;break;case"IdentityUpdated":await R(t.identity.advertising_token)}})}catch(e){console.warn("Did not setup uid2 hooks: ",e)}}function P(){var e,t=__gpp("getGPPData"),t={gppString:t?.gppString,gppSid:t?.applicableSections?.join(",")};return void 0===t.gppString&&(e=__gpp("ping"),t.gppString=e?.gppString,t.gppSid=e?.applicableSections?.join(",")),t}function k(e,t){var n;L?__gpp("removeEventListener",function(){},e.listenerId):"signalStatus"===e.eventName&&"ready"===e.data&&(n=P(),clearTimeout(E),b=new Date,N(n.gppString,n.gppSid),__gpp("removeEventListener",function(){},e.listenerId))}function T(){L=!0,I()}function U(){_=!0,I()}function j(e){_||(e.cmpLoaded||e.gdprAppliesGlobally?(clearTimeout(h),b=new Date,__cmp("getConsentData",null,I)):setTimeout(function(){__cmp("ping",null,j)},200))}function I(e){null!=b&&(u=u+"&ret="+(new Date-b)),_&&(u+="&pto=1"),null!=e&&(u=u+"&gdpr="+(e.gdprApplies?"1":"0")+"&gdpr_consent="+e.consentData),A()}function A(){var e="universal_pixel_"+t.join("_");n(u),C(u,e,"TTD Universal Pixel")}async function R(e){C(await O+"&uiddt="+e,"universal_pixel_"+t.join("_")+"_uid","TTD Universal Pixel with UID")}function C(e,t,n){let i=document.getElementById(t);for(;i&&i.parentElement.removeChild(i),i=document.getElementById(t););let o=document.createElement("iframe");function r(){l.appendChild(o)}o.setAttribute("id",t),o.setAttribute("height",0),o.setAttribute("width",0),o.setAttribute("style","display:none;"),o.setAttribute("src",e),o.setAttribute("title",n),"complete"===document.readyState?setTimeout(r,0):window.addEventListener?window.addEventListener("load",r):window.attachEvent?window.attachEvent("onload",r):r()}function W(){S=!0,I()}function M(e,t){S?__tcfapi("removeEventListener",2,function(e){},e.listenerId):t&&(clearTimeout(D),t=e,null!=b&&(u=u+"&ret="+(new Date-b)),S&&(u+="&pto=1"),null!=t&&(u=u+"&gdpr="+function(e){return e?"1":"0"}(t.gdprApplies)+"&gdpr_consent="+t.tcString),A(),b=new Date,__tcfapi("removeEventListener",2,function(e){},e.listenerId))}function N(e,t){null!=b&&(u=u+"&ret="+(new Date-b)),null!=e&&(u=u+"&gpp_consent="+e),null!=t&&(u=u+"&gpp_sid="+t),A()}}}}}